package cn.zl.api.dto.login;

import cn.yunbamboos.rest.service.anno.param.ParamType;
import cn.yunbamboos.rest.service.anno.param.enums.Type;
import cn.yunbamboos.rest.service.dto.in.GenericInDTO;
import com.alibaba.fastjson2.JSONObject;
import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

public class LoginInDTO extends GenericInDTO {

    /**
     * 登录账号
     */
    @NotNull(message = "登录账号不能为空")
    @Length(min = 4, max = 20, message = "登录账号长度不正确")
    @ParamType(path = "login_name", type = Type.String, title = "登录账号", required = true, example = "admin")
    private String loginName;
    /**
     * 登录密码
     */
    @NotNull(message = "登录密码不能为空")
    @Length(min = 4, max = 40, message = "登录密码长度不正确")
    @ParamType(path = "password", type = Type.String, title = "登录密码", required = true, example = "123456")
    private String password;

    @Override
    public void decode(JSONObject json) {
        super.decode(json);
        this.loginName = this.getString(json, "login_name");
        this.password = this.getString(json, "password");
    }

    /**
     * 获取请求参数登录账号
     *
     * @return 登录账号
     */
    public String getLoginName() {
        return loginName;
    }

    /**
     * 获取请求参数登录密码
     *
     * @return 登录密码
     */
    public String getPassword() {
        return password;
    }

}
